﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DTgame_Turret_Trigger : MonoBehaviour
{
    public GameObject turret;
    TDgameTuret turret_ClassObj;
    private void Awake()
    {
        turret_ClassObj = turret.GetComponent<TDgameTuret>();
    }
    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        turret_ClassObj.enemyList.Remove(null);
    }

    private void OnTriggerEnter(Collider other)
    {
        //print(0);
        if(other.tag.Equals("Enemy"))
        {
            //print(1);
            turret_ClassObj.enemyList.Add(other.gameObject);
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if(other.tag.Equals("Enemy"))
        {
            turret_ClassObj.enemyList.Remove(other.gameObject);
        }
    }
}
